$(function(){
    $('#pantallaLoading').hide();
    $("ul.nav-list:has(li.active)").children("li.nav-last").height($(window).height() - 200 - ($("ul.nav-list .nav-header").height() + 7) * ($("ul.nav-list").length) - $("ul.nav-list:has(li.active) li:not(.nav-last):not(.nav-header)").length * ($("li:not(.nav-last):not(.nav-header)").height()));
    $("ul.nav-list:not(:has(li.active))").each(function(){
        $(this).children(".nav-header").addClass("inactive");
        $(this).children(":not(.nav-header)").hide();
    });
    $("ul.nav-list .nav-header").on('click', function(){   
        $self = $(this); 
        $self.removeClass("inactive");
        $self.siblings("li.nav-last").height($(window).height() - 200 - ($("ul.nav-list .nav-header").height() + 7) * ($("ul.nav-list").length) - $self.siblings("li:not(.nav-last):not(.nav-header)").length * ($("li:not(.nav-last):not(.nav-header)").height()));
        $siblings = $(this).siblings("[visible='visible']");
        if(!$siblings.is(":visible")){
            $("ul.nav-list li:visible:not(.nav-header)").slideUp(500);  
            $activeSiblings = $("ul.nav-list li:visible:not(.nav-header)").siblings(".nav-header");
            $siblings.slideDown(500, function(){     
                $activeSiblings.addClass("inactive"); 
            });
        }
    });
    //funcion para desasignar pendiente
//    console.log('usuaria id:'+$('#userId').val()+ baseUrl);
    $.post(baseUrl+'/index.php/pendientes/default/desasignarGestion',
            {
                'usuario_id': $('#userId').val()
            },function(data) {
//        console.log('data');
    }).complete(function (){
        
    })
});

var topbar = function(e) {
    if($(e.target).parents("li").attr("id") == 'atrasTab'){
        history.back();
    }else if($(e.target).parents("li").attr("id") == 'adelanteTab'){
        history.forward();
    }
}

function showFieldLoading(element){   
   element.hide();
   element.parent().append('<img class="loading" src="' + baseurl + '/images/ajax-loader.gif" alt="">'); 
} 

function hideFieldLoading(element){
   $('img.loading').delay(100).hide(2, function(){
       $('img.loading').remove();
       element.show();
   }); 
}
